package com.davai.castorplay;

import java.io.FileReader;
import java.io.IOException;

import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.InputSource;

public class CastorReader {
	public static void main(String args[]) throws MarshalException,
			ValidationException, IOException, MappingException {
		FileReader reader = new FileReader("People1.0.xml");

		Mapping mapping = new Mapping();
		mapping.loadMapping("mapping1.0.xml");
		Unmarshaller unmarshaller = new Unmarshaller(mapping);
		unmarshaller.setMapping(mapping);
		Person person = (Person) unmarshaller.unmarshal(new InputSource(
				reader));
		System.out.println("PERSON 1.0: " + person);

		reader = new FileReader("People2.0.xml");

		mapping = new Mapping();
		mapping.loadMapping("mapping2.0.xml");
		unmarshaller = new Unmarshaller(mapping);
		unmarshaller.setMapping(mapping);
		person = (Person) unmarshaller.unmarshal(new InputSource(
				reader));
		System.out.println("PERSON 2.0: " + person);
	}
}
